using CfgTable;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    /// <summary>
    /// 控制权限 确保只有 UIMapManager 可以直接创建SymbolData实例
    /// 其它类型只能通过IMapSymbolData访问SymbolData实例
    /// 降低错误使用对象池的可能性
    /// </summary>
    public partial class UIMapManager
    {
        protected class BriefMapSymbolData : IMapSymbolData
        {
            #region Property

            public int entityId => _data.entityId;
            public int mcid => _data.entityMcid;
            public bool isOfferingQuest => _data.isOfferingQuest;
            public CfgMapUiEntity config { get; set; }
            public string iconPath => config.Icon_fullPath;
            public string effectPath => config.Effect_fullPath;
            public Quaternion worldRotation => _data.rotation;
            public Vector3 worldPosition => _data.position;

            public object GetRawData()
            {
                return _data;
            }

            public bool isCheckPointActive => _data.isCheckPointActive;
            public int layer { get; set; }

            #endregion

            #region Exposed Method

            public void SetRawData(object data)
            {
                if (data is not MainUIEntityData entityData) return;
                _data = entityData;
                config = TableCenter.mapUiEntity.Get(entityData.mapUIEntityCid);
                layer = (int)config.StaticLayer;
            }

            #endregion

            #region IReusableClass Implement

            public uint MaxStore => 30;

            public void OnReset()
            {
                _data = null;
                config = null;
            }

            #endregion

            #region Field

            private MainUIEntityData _data;

            #endregion
        }
    }
}